import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/data/entities/closure/access_record_entity.dart';
import 'package:enterprise_v6_app/app/modules/task/task_all/task_closure/common/common_closure_method.dart';

/// 车辆-出入记录-基本信息
class AssessBasicInfoCar extends StatelessWidget {
  const AssessBasicInfoCar({required this.item, super.key});

  final AccessRecordEntity item;

  /// 信息列表
  Widget _widget() {
    return Column(
      children: [
        _buildBasicInfoItem(
          '驾驶员姓名:',
          '${item.name}',
        ),
        _buildBasicInfoItem(
          '所属企业:',
          '${item.affiliatedUnit}',
        ),
        _buildBasicInfoItem(
          '道路运输证号:',
          '${item.inGateId}',
        ),
        _buildBasicInfoItem(
          '运输介质:',
          '${item.transportMedium}',
        ),
        _buildBasicInfoItem(
          '来访事由:',
          '${item.reasonForVisit}',
        ),

      ],
    );
  }

  /// 基本信息
  Widget _buildBasicInfoItem(
    String key,
    String val, {
    bool isRequired = false,
    bool isPic = false,
  }) {
    return Padding(
      padding: EdgeInsets.symmetric(horizontal: 37.w, vertical: 6.w),
      child: Row(
        children: [
          SizedBox(
            width: 120.w,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.start,
              children: [
                if (isRequired)
                  Text(
                    '*',
                    style: TextStyle(
                      fontSize: 13.sp,
                      color: Colors.red,
                    ),
                    textAlign: TextAlign.center,
                  ),
                Text(
                  key,
                  style: TextStyle(
                    fontSize: 14.sp,
                    color: const Color(0xFF7C7D93),
                  ),
                )
              ],
            ),
          ),
          isPic
              ? SizedBox(
                  height: 77.w,
                  width: 77.w,
                  child: Image.network(val),
                )
              : Expanded(
                  child: Text(
                    val,
                    style: TextStyle(
                      fontSize: 12.sp,
                      color: const Color(0xFF495061),
                    ),
                  ),
                ),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      child: Column(
            children: [
              Container(
                height: 38.w,
                width: double.infinity,
                color: AppColors.bg_color_grey,
                alignment: Alignment.centerLeft,
                padding: EdgeInsets.only(left: 16.w),
                child: Text(
                  '基本信息',
                  style: TextStyle(
                    fontSize: 12.sp,
                    color: AppColors.text_grey,
                  ),
                ),
              ),
              Container(
                height: 2.w,
                color: AppColors.blue_button,
              ),
              Container(
                height: 64.w,
                color: const Color(0xFFF4F7FF),
                child: Row(
                  children: [
                    AppGaps.hGap36,
                    Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text(
                          '车牌号码：${item.licensePlate}',
                          style: TextStyle(
                            fontSize: 16.sp,
                            fontWeight: FontWeight.w500,
                          ),
                        ),
                        AppGaps.vGap4,
                        Text(
                          '车辆类型: ${CommonClosureMethod.getCarTypeValue(item.carType)}',
                          style: TextStyle(
                            fontSize: 13.sp,
                            color: const Color(0xFF3F425B),
                          ),
                        ),
                      ],
                    ),
                  ],
                ),
              ),
              Container(
                height: 1.w,
                color: AppColors.divider_color_blue,
              ),
              AppGaps.vGap14,
              _widget(),
            ],
          ),
    );
  }
}
